#include "common.h"
namespace common {
int countSubstrings(std::string s) {
    const int n = s.size();
    int left = 0, right = 0, result = 0;
    for (int i = 0; i < 2 * n - 1; i++) {
        left = i / 2;
        right = i / 2 + i % 2;
        while (left >= 0 && right < n && s[left] == s[right]) {
            left--;
            right++;
            result++;
        }
    }
    return result;
}
} // namespace common
